<template>
  <el-table :data="dataList" border fit highlight-current-row @selection-change="handleSelectionChange">
    <el-table-column type="selection" width="55">
    </el-table-column>
    <!-- <el-table-column v-for="(item) in engTh" :key="item" :prop="item" :label="formTh[`${item}`]" /> -->
    <el-table-column v-for="(item) in engTh" :key="item" :label="formTh[`${item}`]">
      <template v-slot="scope">
        <!-- {{ handleItem(item, scope.row[`${item}`]) }} -->
        {{ scope.row[`${item}`] }}
      </template>
    </el-table-column>

    <!-- <el-table-column fixed="right" label="操作" width="150">
      <template v-slot="scope">
        <el-button type="success" size="small" @click="showJournalList(scope.row.businessId)">查看分录信息</el-button>
      </template>
    </el-table-column> -->

  </el-table>
</template>

<script lang="ts" setup>
import { CostTransactionProcess } from "@/requests/request";
import { exportExcel, filterExcelContentArr } from "@/utils/excel";
// import { timeFormat } from "@/utils/time"
import { journalTableHeader, purTableHeader, purTableProps } from "../data";
import { onMounted } from "vue";

defineProps({
  dataList: Array<CostTransactionProcess>,
  engTh: Array<String | null>
});
const formTh = Object.assign(purTableHeader, journalTableHeader)
// const emit = defineEmits(['showJournalList'])
// const showJournalList = (businessId: string) => {
//   emit('showJournalList', businessId);
// }
onMounted(() => {
  console.log('数据', formTh)
})

let selectedArr: Array<any> = []
const handleSelectionChange = (val: Array<any>) => {
  console.log('选择的值', val);
  selectedArr = val;
}
const exportItems = () => {
  const sheetArr = filterExcelContentArr(selectedArr, purTableProps, purTableHeader)
  console.log('过滤的值', sheetArr)
  exportExcel("事务处理明细.xlsx", sheetArr)

}
// 暴露出去被引用
defineExpose({
  exportItems
})
// enum accountingTypeEnum {
//   "入库检验" = 1,
//   "库存估价" = 2,
//   "采购价格差异或汇率差异" = 3,
// }
// const handleItem = (key: any, value: any) => {
//   if (key === 'accountingType') {
//     return accountingTypeEnum[value]
//   } else {
//     return value
//   }
// }
</script>
<style lang="scss" scoped></style>